package com.wn.production.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.wn.common.PageBean;
import com.wn.entity.Process;
import com.wn.production.mapper.ProcessMapper;
import com.wn.production.service.ProcessService;
import com.wn.production.vo.ProcessVo;
import com.wn.utils.CurrentTime;
import com.wn.utils.OssManagerUtil;
import com.wn.utils.PageBeanUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ProcessMapperImpl implements ProcessService {
    @Autowired
    private ProcessMapper processMapper;
    @Override
    public void insert(Process process) {
        OssManagerUtil ossManagerUtil=new OssManagerUtil();
        String number="KFC"+CurrentTime.getCurrentTimeString();
        process.setProcessNumer(number);
        processMapper.insert(process);

    }

    @Override
    public PageBean<Process> getByCondition(ProcessVo processVo) {
        Page<Process> page = PageHelper.startPage(processVo.getCurrPage(), processVo.getPageSize());
        List<Process> list = processMapper.getByCondition(processVo.getProcess());
        return PageBeanUtil.getPageBean(list,page,processVo.getCurrPage(),processVo.getPageSize());
    }

    @Override
    public void update(Process process) {
        processMapper.update(process);
    }
}
